#version 120

// vehicle.vert



uniform mat4 projection_matrix;
uniform mat4 modelview_matrix;
uniform mat3 normal_matrix;

attribute vec3 a_vertex;
attribute vec3 a_normal;
attribute vec2 a_tex_coord;

uniform vec4 Light_Position;
uniform vec4 Sky_Colour;
uniform vec4 Ground_Colour;

varying vec2 st;
//varying vec3 skyColour;
//varying vec3 groundColour;
//varying lightPos;

varying vec4 colour;

void main()
{
	//vec4 ecPosition = vec3(gl_ModelViewMatrix * gl_Vertex);
	vec4 ecPosition = modelview_matrix * vec4(a_vertex, 1.0);
	vec3 ecPos3 = (vec3(ecPosition)) / ecPosition.w;
    vec3 lightVec = normalize(Light_Position.xyz - ecPos3.xyz);
    vec3 normal = normalize(normal_matrix * a_normal);
    float costheta = dot(normal, lightVec);
  	//float a = 0.5 + 0.5 * costheta;  
    
     float a = 0.5 + 0.5 * normal.y;
    //colour = mix(Ground_Colour, Sky_Colour, a);
    colour = (a* Sky_Colour) + (a* Ground_Colour);
               

          
    st = a_tex_coord;
    gl_Position = projection_matrix * modelview_matrix * vec4(a_vertex, 1.0);
}

